package com.one.common.manager.imagchoose;

/**
 * Author：zhulunjun
 * Time：2017/10/9
 * description：图片选择库管理，可任意更换，不影响调用
 */

public class ChooseManager {

    private static IChooseImg innerChooser;
    private static IChooseImg externalLoader;

    public static void setChooser(IChooseImg chooser) {
        if (externalLoader == null && chooser != null) {
            externalLoader = chooser;
        }
    }

    public static IChooseImg getChooser() {
        if (innerChooser == null) {
            synchronized (ChooseManager.class) {
                if (innerChooser == null) {
                    if (externalLoader != null) {
                        innerChooser = externalLoader;
                    } else {
                        innerChooser = new ImagePickerChoose();
                    }
                }
            }
        }
        return innerChooser;
    }
}
